

#include "skeletalHead.h"
#include "renderer.h"

SkeletalHead::SkeletalHead(){

name="SkeletalHead";
mouthUp=NULL;
mouthDown=NULL;
mouthOpen=0.0f;
registerProperties();
}

SkeletalHead::~SkeletalHead(){}

void SkeletalHead::registerProperties(){

SkeletalActor::registerProperties();
createMemberID("MOUTHOPEN",&mouthOpen,this);
createMemberID("MOUTHUP",&mouthUp,this);
createMemberID("MOUTHDOWN",&mouthDown,this);
}

void SkeletalHead::setup(){

    SkeletalActor::setup();

    if (!mouthUp){
        for (int i=0;i<(int)bones.size();i++){
            if (bones[i]->name=="mouthUp"){
                mouthUp=bones[i];
                baseMouthMatrix=mouthUp->transformMatrix;
                cout << "yay!!! Found mouth!!" << endl;
            }
        }
    }
}

void SkeletalHead::trigger(Actor * other){}

void SkeletalHead::update(double deltaTime){

    SkeletalActor::update(deltaTime);

    if (mouthUp){
        mouthUp->transformMatrix.setTranslation(Vector3f(0,mouthOpen,0));
        //mouthUp->transformMatrix=baseMouthMatrix * mouthUp->transformMatrix;
    }
}

void SkeletalHead::create(){renderer->addActor(this);}
